# conding utf-8
from selenium.webdriver import ActionChains, Keys

from pages.gzy.goods.category import left_menu, left_menu_sys, insert_catalog_btn, catalog_name, catalog_ref, \
    catalog_sort, catalog_remaker, insert_qr_btn, catalog_check, choice_catalog_btn, senior_catalog, catalog_expected
from pages.page import Page


class CategoryPage(Page):

    def open_category(self):
        #打开商品ui，如果已经打开则不会执行单击动作
        if self.display(left_menu) is False:  # 如果是隐藏状态则单击
            self.click(left_menu_sys)
        self.click(left_menu)

    def click_insert_category(self):
        self.click(insert_catalog_btn)

    def insert_catalog(self,catalog_namev,catalog_refv,catalog_sortv,catalog_remakerv):
        self.send_keys(catalog_name,catalog_namev)
        self.send_keys(catalog_ref,catalog_refv)
        self.send_keys(catalog_sort,catalog_sortv)
        self.send_keys(catalog_remaker,catalog_remakerv)

    def click_bc(self):
        self.click(insert_qr_btn)

    def check_catalog(self):
        self.click(catalog_check)

    def choice_catalog(self):
        self.click(choice_catalog_btn)
        self.click(senior_catalog)

    def expected_eval(self,expected):
        return self.find_element(eval(expected)).text

    def catalog_expected(self):
        self.find_element(catalog_expected)
